<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<title>用户删除</title>
<head>
<script type="text/javascript">
</script>
</head>
<body>
<div class="jianju" style="height: 1000px;">
<h3>用户删除</h3>

<div id="tb" style="padding:5px;height:auto">
<hr/>
	<div>
	<input value="${id}" id="hiddenid" hidden="hidden"/>
	<input id="modifyCount" hidden="hidden"/>
	  <label style="margin-left:18px">登陆代码：</label><input class="easyui-textbox" id="userId" type="number" style="width:120px" readonly="readonly">
	  <label style="margin-left:18px">用户姓名：</label><input class="easyui-textbox" id="userName" style="width:110px" readonly="readonly"><br />
	  <label style="margin-left:18px">所属公司：</label>
	     <select id="ssgs" class="easyui-combobox" style="width: 100px" 
			mode="remote" url="${ctx}/contractadvancedquery/findUnderCompany" valueField="id"
			textField="orgName" method="get" editable="false" panelHeight="auto">
		 </select><br />
	  <label style="margin-left:18px">用户角色：</label>
	     <select id="yhjs" class="easyui-combobox" style="width: 100px" 
			mode="remote" url="${ctx}/Boxuser/userfindName" valueField="roleId"
			textField="roleName" method="get" editable="false" panelHeight="auto">
		 </select>
	  <label style="margin-left:18px">联系电话：</label><input type="number" class="easyui-textbox" id="phone" style="width:110px"  readonly="readonly"><br />
	  <label style="margin-left:18px">备用手机号码：</label><input type="number" class="easyui-textbox" id="mobile" type="number" style="width:120px"  readonly="readonly">
	  <label style="margin-left:18px">电子邮件：</label><input class="easyui-textbox" id="email" style="width:110px"  readonly="readonly"><br />
	  <label style="margin-left:18px">用户备注：</label><textarea class="easyui-textbox" id="memo" style="width:220px;height: 50px;" readonly="readonly"></textarea><br />
		 <br />
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" onclick="deleted();">删除</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:reload();">返回</a>
	</div>
	</div> 
</div> 
<script type="text/javascript">
function reload(closeFlag){
	window.history.go(-1);
} 
var id = $("#hiddenid").val();
$(function(){
	$('#ssgs').combobox({
		onLoadSuccess : function() {
			var data = $('#ssgs').combobox('getData');
			if (data) {
				$("#ssgs").combobox('select', data[0].id);
			}
		}
	}); 
	$('#yhjs').combobox({
		onLoadSuccess : function() {
			var data = $('#yhjs').combobox('getData');
			if (data) {
				$("#yhjs").combobox('select', data[3].roleId);
			}
		}
	}); 
	$.ajax({
		url:"${ctx}/Boxuser/get",
		data:{"id":id},
		success:function(data){debugger
			 $("#userId").textbox("setValue", data.userId);
			 $("#userName").textbox("setValue", data.userName);
			 $("#ssgs").combobox('select',data.underCompany);
			 $("#yhjs").combobox('select',data.roleId);
			 $("#phone").textbox("setValue", data.phone);
			 $("#mobile").textbox("setValue", data.mobile);
			 $("#email").textbox("setValue", data.email);
			 $("#memo").textbox("setValue", data.memo);
			 $("#modifyCount").val(data.modifyCount);
		}
	});
});

function deleted(){debugger
	$.ajax({
		url:"${ctx}/Boxuser/updateById",
		data:{"userId":id},
		success:function(data){
			if(data > 0){
				alert("有该用户做成的合同，不允许删除！");
			}else{
				var modifyCount = $("#modifyCount").val();
				var count = parseInt(modifyCount)+1;
				$.ajax({
					url:"${ctx}/Boxuser/delete",
					data:{"id":id,"modifyCount":count},
					success:function(data){debugger
						if(data.result == 1){
							alert("删除成功！");
						}else{
							alert("删除失败或已删除！");
						}
					}
				}); 
			}
		}
	});
	
}
</script>


</div> 
</body>
</html>